﻿<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn"	uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<!DOCTYPE html>
<html>
  <head>
  	
  	<%@ include file="/WEB-INF/include/meta.jsp" %>
  	<%@ include file="/WEB-INF/include/css.jsp" %>
	<link href="${ctx.resource}/css/bootstrap-switch.min.css" rel="stylesheet">
	
	<title>${startup.profile.name} - 众投湾</title>
	
	<fmt:setBundle basename="ApplicationMessage"/>
	<fmt:setLocale value="zh_CN"/>
	
  </head>

  <body>
  
	<%@ include file="/WEB-INF/include/header.jsp" %>
	
	  <div class="container">
	  
	    <div class="zz-startup-cover">
	      <a class="zz-startup-avatar-wrapper" href="${ctx}/startups/${startup.id}">
	        <img class="img-thumbnail" src="${ctx.upload}/${startup.profile.avatar}">
	      </a>
	      
	      <div class="zz-startup-cover-letter">
	        <div class="zz-startup-cover-title">${startup.profile.name}</div>
	        <span class="font-size-14 label label-success" style="font-weight: normal;">
	          <fmt:message key="${startup.profile.businessStatus.key}" /><c:if test="${not empty startup.profile.supplement}">（${startup.profile.supplement}）</c:if>
	        </span>&nbsp;
	        <span class="font-size-14 label label-success" style="font-weight: normal;">
	          <fmt:message key="${startup.fundStatus.key}" />
	        </span>
	        <p class="line-ellipsis font-size-16 bottom-margin-15">${startup.profile.alias}</p>
	        <p class="line-ellipsis text-deep-gray font-size-14 bottom-margin-15">
	          <i class="glyphicon glyphicon-map-marker"></i>&nbsp;${startup.profile.region}&nbsp;&nbsp;&nbsp;&nbsp;
	          <i class="glyphicon glyphicon-tags"></i>
	          <c:forEach var="tag" items="${fn:split(startup.tags, ',')}" varStatus="count">
	          	<c:choose>
	          	  <c:when test="${count.index == 0}">
	          	    &nbsp;${tag}
	          	  </c:when>
	          	  <c:otherwise>
	          	    &nbsp;<strong>·</strong>&nbsp;${tag}
	          	  </c:otherwise>
	          	</c:choose>
	          </c:forEach>
	        </p>
	        
        	<c:if test="${isLoginUser}">
	        <div class="operation-button-groups">
	          <c:choose>
			  <c:when test="${isSubscribed}">
	          	<a href="javascript:unsubscribe(${startup.id});" id="subscribe-btn" class="btn btn-success demo2do-input-small-width">取消关注</a>
			  </c:when>
			  <c:otherwise>
	          	<a href="javascript:subscribe(${startup.id});" id="subscribe-btn" class="btn btn-success demo2do-input-small-width">关注</a>
			  </c:otherwise>
			  </c:choose>

	          <a href="#" class="btn btn-primary  demo2do-input-small-width">分享</a>
	        </div>
			</c:if>
	      </div><!-- zz-startup-cover-letter -->
	      
	      <ul class="nav nav-tabs zz-startup-tabs">
	        <li class="active"><a href="javascript: void(0)">项目概况</a></li>
	        <li><a href="${ctx}/startups/${startup.id}/finance">投资逻辑</a></li>
	        <li><a href="${ctx}/startups/${startup.id}/team">团队简介</a></li>
	        <li><a href="${ctx}/startups/${startup.id}/events">项目动态</a></li>
	      </ul>
	    </div><!-- zz-startup-cover -->
	    
	    <div class="zz-startup-content">
	    
	      <sec:authorize access="isAuthenticated()">
	        <c:if test="${startup.funding}">
	          
	          <div class="panel panel-default zz-startup-fund-panel">
		        <div class="panel-body no-padding clearfix">
		          
		          <div class="zz-startup-fund-progress-block">
		          
		            <div class="bottom-padding-10">
		              <a class="btn btn-primary zz-startup-apply-btn pull-right font-size-14" href="${ctx}/startups/${startup.id}/fund-progress/create" data-target="#" data-toggle="modal">立即参与</a>
		              <p class="lead">正在合投中...</p>
		            </div>
		            
		            <div class="startup-fund">
		            
		              <div class="progress zz-progress ${startup.fund.fundedPercentage > 1 ? 'zz-overfunded-progress' : ''}">
		                <fmt:formatNumber value="${startup.fund.fundedPercentage}" type="percent" /><c:if test="${startup.fund.fundedPercentage >= 1}">（合投成功）</c:if>
		          	    <div class="progress-bar" style='width: <fmt:formatNumber value="${startup.fund.fundedPercentage}" type="percent" />;'></div>
		              </div>
		              
		              <div class="fund-data-list text-muted">
		               <div class="pull-left"><b>&yen;</b>&nbsp;<b class="text-primary" title="已获认购"><fmt:formatNumber value="${startup.fund.fundedSum}" type="number"/>万</b><br>已获认购</div>
		              <div class="pull-right text-align-right"><b>&yen;</b>&nbsp;<b class="text-primary" title="期望融资"><fmt:formatNumber value="${startup.fund.total}" type="number" />万</b><br>期望融资</div>
		              <div><b title="剩余时间">${startup.fund.remainingDays}天</b><br>剩余时间</div>
		              </div>
		            </div>
		            
		          </div><!-- zz-startup-fund-progress-block -->
		          
		          <div class="zz-startup-fund-block">
		            <label class="col-md-4 text-align-right">融资时间</label>
		            <p class="col-md-7"><fmt:formatDate value="${startup.fund.startDate}" pattern="MM月dd日"/>&nbsp;-&nbsp;<fmt:formatDate value="${startup.fund.endDate}" pattern="MM月dd日"/></p>
		            <label class="col-md-4 text-align-right">融资总额</label>
		            <p class="col-md-7 text-primary"><b><span class="text-muted">&yen;</span>&nbsp;<fmt:formatNumber value="${startup.fund.total}" type="number" />万</b></p>
		            <label class="col-md-4 text-align-right">出让股份</label>
		            <p class="col-md-7 text-primary"><b>&nbsp;<fmt:formatNumber value="${startup.fund.share}" type="number" />%</b></p>
		            <label class="col-md-4 text-align-right">最小投资额</label>
		            <p class="col-md-7 text-primary"><b><span class="text-muted">&yen;</span>&nbsp;<fmt:formatNumber value="${startup.fund.minimum}" type="number" />万</b></p>
		            <label class="col-md-4 text-align-right">融资状态</label>
		            <p class="col-md-7 text-primary">${startup.fund.leaded ? '已被领投' : '未被领投'}</p>
		          </div>
		          
		        </div>
		      </div><!-- zz-startup-fund-panel -->
	          
	        </c:if>
	      </sec:authorize>
	      
	      <div class="col-lg-8 col-md-8 zz-startup-left-layout">
	        
	        <div class="panel panel-default zz-startup-panel">
	          <div class="panel-heading zz-startup-panel-heading"><b>项目概述</b></div>
	          <div class="panel-body">
	            <p>${startup.profile.description}</p>
	          </div>
	        </div>
	        
	        <div class="panel panel-default zz-startup-panel">
	          <div class="panel-heading zz-startup-panel-heading"><b>项目展示</b></div>
	          <div class="panel-body">
	            
	            <div id="startup-resource-show" class="carousel slide ${empty startup.resources ? 'hidden' : ''}" data-ride="carousel">
	            
	              <ol class="carousel-indicators">
	                <c:forEach var="item" items="${startup.pictureResources}" varStatus="count">
	                  <li data-target="#startup-resource-show" data-slide-to="${count.index}" class="${count.index == 0 ? 'active' : ''}"></li>
	                </c:forEach>
	              </ol>
	              
	              <div class="carousel-inner zz-startup-resource-carousel">
	                <c:forEach var="item" items="${startup.resources}" varStatus="count">
	                  <div class="item ${count.index == 0 ? 'active' : ''}">
	                    <img src="${ctx.upload}/${item.url}">
	                  </div>
	                </c:forEach>
	              </div>
	              
	              <a class="left carousel-control" href="#startup-resource-show" data-slide="prev">
	                <span class="glyphicon glyphicon-chevron-left"></span>
	              </a>
	              <a class="right carousel-control" href="#startup-resource-show" data-slide="next">
	                <span class="glyphicon glyphicon-chevron-right"></span>
	              </a>
	              
	            </div>
	            
	          </div>
	        </div>
	        
	      </div><!-- zz-startup-left-layout -->

		  <%@ include file="/WEB-INF/jsps/startup/include/right-layout.jsp" %>

	      
	    </div><!-- zz-startup-content -->
	    
	  </div>
	
	<%@ include file="/WEB-INF/include/footer.jsp" %>
	<%@ include file="/WEB-INF/include/script.jsp" %>
	<script src="${ctx.resource}/js/jquery.raty.min.js"></script>
	<script src="${ctx.resource}/js/bootstrap-modal-trigger.js"></script>
	<script src="${ctx.resource}/js/bootstrap.validate.js"></script>
    <script src="${ctx.resource}/js/bootstrap.validate.en.js"></script>
    <script src="${ctx.resource}/js/bootstrap-switch.min.js"></script>
	
	<script>
	
	  function subscribe(id) {
	    $.get("${ctx}/startups/"+id+"/subscribe",function(data,status){
		  if(data) {
		    $('#subscribe-btn').text('取消关注');
		    $('#subscribe-btn').attr('href', 'javascript:unsubscribe('+id+');');
		  }
	    });
	  }

	  function unsubscribe(id) {
	    $.get("${ctx}/startups/"+id+"/unsubscribe",function(data,status){
	      if(data) {
		    $('#subscribe-btn').text('关注');
		    $('#subscribe-btn').attr('href', 'javascript:subscribe('+id+');');
		  }
	    });
	  }

	  $(function() {
		$(".show-rating").raty({
		  path      : "${ctx.resource}/img",
		  half      : true,
		  target    : ".show-rating-hint",
		  readOnly  : true,
		  score     : function() {
		    return $(this).data("score");
		  }
		});
		
		$(".show-rating").each(function() {
		  $(this).next().text($(this).data("score"));
		});
	  });
	  
	</script>
    
  </body>
  
</html>
